home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / utilities / easyproc2.lha / EasyProcess / loop / Loop.c next >
Encoding:
C/C++ Source or Header  |  1992-11-05  |  1.5 KB  |  82 lines

  1. #ifdef KICK_13
  2. #include <libraries/arpbase.h>
  3. #include <clib/arp_proto.h>
  4. #endif
  5. #include "source:launch/Launch.h"
  6.  
  7.  
  8. void main (WORD argc, char *argv[]);
  9. void Reader (BPTR File[2]);
  10.  
  11. #ifdef KICK_13
  12. struct ArpBase *ArpBase;
  13. #endif
  14.  
  15. #define F_IN    0
  16. #define F_OUT    1
  17.  
  18. void main (WORD argc, char *argv[])
  19. {
  20.     extern struct Library *DOSBase;
  21.     struct Process *Proc1, *Proc2;
  22.     BPTR HC[2];
  23.     BPTR RAW[2];
  24.  
  25.     if (argc < 3)
  26.     {
  27.         puts ("Specify two file to link.\n\nFor example: Loop hc:1 \"raw:0/0/640/100/HC11 numer 1\"");
  28.         exit (5);
  29.     }
  30. #ifdef KICK_13
  31.     ArpBase = (struct ArpBase *)OpenLibrary ("arp.library", 33L);
  32.     if (ArpBase)
  33. #endif
  34.     {
  35.         RAW[F_OUT] = HC[F_IN] = Open (argv[1], MODE_NEWFILE);
  36.         if (HC[F_IN] && IsInteractive ( HC[F_IN] ))
  37.         {
  38.             RAW[F_IN] = HC[F_OUT] = Open (argv[2], MODE_NEWFILE);
  39.             if (HC[F_OUT] && IsInteractive(HC[F_OUT]))
  40.             {
  41.                 Proc1 = StartProcess ("HC Server", Reader, HC, 1);
  42.                 if (Proc1)
  43.                 {
  44.                     Proc2 = StartProcess ("RAW Server", Reader, RAW, 1);
  45.                     if (Proc2)
  46.                     {
  47.                         Wait (SIGBREAKF_CTRL_C);
  48.                         KillProcess (Proc2);
  49.                         Write (RAW[F_IN], (char *)" ", 1);
  50.                     }
  51.                     KillProcess (Proc1);
  52.                     Write (HC[F_IN], (char *)" ", 1);
  53.                     WaitProcesses ();
  54.                 }
  55.                 Close (HC[F_OUT]);
  56.             }
  57.             Close (HC[F_IN]);
  58.         }
  59. #ifdef KICK_13
  60.         CloseLibrary (ArpBase);
  61. #endif
  62.     }
  63.     exit (0);
  64. }
  65.  
  66.  
  67. void Reader (BPTR File[2])
  68. {
  69.     extern struct Library *DOSBase;
  70.     ULONG Buffer;
  71.  
  72.     while (1)
  73.     {
  74.         if (Read (File[F_IN], &Buffer, 1))
  75.             Write (File[F_OUT], &Buffer, 1);
  76.         if (0 != CheckKill ())
  77.         {
  78.             return;
  79.         }
  80.     }
  81. }
  82.